package com.pangu.mark;

import com.pangu.bean.PageInfo;

/**
 * 分页型的任务分装
 * <p/>
 * Created by cxlin
 */
public class APageTaskMark extends ATaskMark {

	// 页面信息, 初始从0开始
	private PageInfo pageInfo = new PageInfo();

	@Override
	public void reinitTaskMark() {
		super.reinitTaskMark();

		pageInfo = new PageInfo();
	}

	public PageInfo getPageInfo() {
		return pageInfo;
	}

	public void setPageInfo(PageInfo pageInfo) {
		this.pageInfo = pageInfo;
	}

	/**
	 * 设置每页的数量
	 */
	public void setPageSize(int count) {
		pageInfo.setSize(count);
	}

	@Override
	public boolean isLoadEnd() {
		return pageInfo == null
				|| (pageInfo.getTotalCount() != 0 && (pageInfo.getFrom() + pageInfo.getSize() >= pageInfo
						.getTotalCount()));
	}

	/**
	 * 从来没有加载过，初始pageinfo是不为null的。
	 * 
	 * @return
	 */
	public boolean isNeverLoaded() {
		if (pageInfo != null && pageInfo.getTotalCount() == 0) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public String toString() {
		return "APageTaskMark{" + "pageInfo=" + pageInfo + "} " + super.toString();
	}
}
